<?php
/* ================================================================================
 * Application Class 
 *
 * application.class.php: This class is used to drive the application system.
 *
 * Author: Eric Hendrickson (enhendrickson@liberty.edu)
 * Date: 9/5/2005
   ================================================================================ */

class Application
{
	var $ApplicationInfo = 		array (
		'app_id'	=> "",
		'app_name'   	=> "",
		'app_path'   	=> "");
	
	function Application()
	{
	}
	
	function ApplicationInfoByID($appid)
	{
		global $DB;
		$DB->query("SELECT * FROM apps WHERE AppID = '" . $appid . "'");
		$row = $DB->fetch_row();
		$this->ApplicationInfo['app_id'] = $row['AppID'];
		$this->ApplicationInfo['app_name'] = $row['AppName'];
		$this->ApplicationInfo['app_path'] = $row['AppPath'];
	}

	function ApplicationInfoByName($app_name)
	{
		global $DB;
		$DB->query("SELECT * FROM apps WHERE AppName = '" . $app_name . "'");
		$row = $DB->fetch_row();
		$this->ApplicationInfo['app_id'] = $row['AppID'];
		$this->ApplicationInfo['app_name'] = $row['AppName'];
		$this->ApplicationInfo['app_path'] = $row['AppPath'];
	}

	function ApplicationInfoByCurrentLocation()
	{
		global $DB;
		$LocationString = substr(dirname($_SERVER['PHP_SELF']),1,strlen(dirname($_SERVER['PHP_SELF']))) . "/";	
		
		$sql = "select * from apps 
					where AppPath = '{$LocationString}'
					or AppPath ='/{$LocationString}'";
		
		$DB->query($sql);
		$row = $DB->fetch_row();
		$this->ApplicationInfo['app_id'] = $row['AppID'];
		$this->ApplicationInfo['app_name'] = $row['AppName'];
		$this->ApplicationInfo['app_path'] = $row['AppPath'];
	}
}
?>
